<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="../include/tag.jsp"%>
<!DOCTYPE html>
<html lang="zh">
<head>
<title>历史订单管理</title>
<link rel="stylesheet" href="${ctx}/css/common/list.css">
<link rel="stylesheet" href="${ctx}/css/common/table.css">
<%@include file="../include/commonFile.jsp"%>
<style type="text/css">
	.layui-table td, .layui-table th{
		padding-left: 10px!important;
		padding-right: 10px!important;
	}

	.search-container .layui-form-select, .search-container input[type=text] {
		width: 212px!important;
	}

	.layui-table[lay-size=sm] td, .layui-table[lay-size=sm] th {
		font-size: 12.5px !important;
		padding: 9px 10px !important;
	}
</style>
</head><body>
<!--头部-->
<%@include file="../include/header.jsp"%>
<div class="index-outside">
	<%@include file="../include/sidebar.jsp"%>
	<!--内容-->
	<section>
		<div class="section-main">
			<form class="layui-form" action="${ctx}/order/orderHistory/orderList.do" id="myForm" method="post">
				<input type="hidden" name="pageNo" id="pageNo" value="1" />
				<input type="hidden" name="flag" id="flag" value="false" />
				<div class="f-search-bar">
					<div class="search-container">
						<ul class="search-form-content">
							<li class="form-item-inline"><label class="search-form-lable">订单编号</label>
								<div class="layui-input-inline">
									<input type="text" name="id" class="layui-input" value="${orderForm.id}" placeholder="请输入订单编号">
								</div>
							</li>
							<li class="form-item-inline"><label class="search-form-lable">订单名称</label>
								<div class="layui-input-inline">
									<input type="text" name="title" class="layui-input" value="${orderForm.title}" placeholder="请输入订单名称">
								</div>
							</li>
							<li class="form-item-inline"><label class="search-form-lable">商&emsp;&emsp;户</label>
								<div class="layui-input-inline">
									<input type="text" name="merchantId" class="layui-input" value="${orderForm.merchantId}" placeholder="请输入商户">
								</div>
							</li>
						</ul>
						<ul class="search-form-content">
							<li class="form-item-inline"><label class="search-form-lable" style="margin-left: 14px;">下单者</label>
								<div class="layui-input-inline">
									<input type="text" name="memberName" class="layui-input" value="${input.memberName}" placeholder="请输入订单下单者" >
								</div>
							</li>
							<li class="form-item-inline"><label class="search-form-lable" style="margin-left: 14px;">所属者</label>
								<div class="layui-input-inline">
									<input type="text" name="initiatorName" class="layui-input" value="${initiatorName}" placeholder="请输入订单所属者" >
								</div>
							</li>
							<li class="form-item-inline">
								<label class="search-form-lable">支付方式</label>
								<div class="layui-input-inline">
									<select name="paymentWay">
										<option value="">全部</option>
										<option value="1" ${orderForm.paymentWay == '1' ? 'selected="selected"' : ''}>微信</option>
										<option value="0" ${orderForm.paymentWay == '0' ? 'selected="selected"' : ''}>支付宝</option>
									</select>
								</div>
							</li>
						</ul>
						<ul class="search-form-content">
							<li class="form-item"><label class="search-form-lable">更新时间</label>
								<div class="check-btn-inner" id="timeType">
									<a href="javascript:void(0);" onclick="setTimeType($(this),0,'#myForm')" ${empty input.timeType || input.timeType == 0 ? 'class="active"' : ''}>全部</a>
									<a href="javascript:void(0);" onclick="setTimeType($(this),4,'#myForm')" ${input.timeType == 4 ? 'class="active"' : ''}>昨天</a>
									<a href="javascript:void(0);" onclick="setTimeType($(this),1,'#myForm')" ${input.timeType == 1 ? 'class="active"' : ''}>今天</a>
									<a href="javascript:void(0);" onclick="setTimeType($(this),2,'#myForm')" ${input.timeType == 2 ? 'class="active"' : ''}>本周内</a>
									<a href="javascript:void(0);" onclick="setTimeType($(this),3,'#myForm')" ${input.timeType == 3 ? 'class="active"' : ''}>本月内</a>
									<input type="hidden" name="timeType" value="${input.timeType}" />
								</div>
								<div class="layui-inline">
									<div class="layui-input-inline">
										<input class="layui-input" type="text" name="createStart" value="${input.createStart}" placeholder="开始日">
									</div>
									-
									<div class="layui-input-inline">
										<input class="layui-input" type="text" name="createEnd" value="${input.createEnd}" placeholder="截止日">
									</div>
								</div>
							</li>
							<%--<li class="form-item-inline"><label class="search-form-lable">手机号码</label>
								<div class="layui-input-inline">
									<input type="text" name="phone" class="layui-input" value="${orderForm.phone}" placeholder="请输入手机号码">
								</div>
							</li>--%>
						</ul>
						<ul class="search-form-content">
							<li class="form-item"><label class="search-form-lable">订单类型</label>
								<div class="check-btn-inner">
									<a href="javascript:void(0);" onclick="setTimeType($(this),'','#myForm')" ${empty orderForm.type ? 'class="active"' : ''}>全部</a>
									<c:forEach var="map" items="${orderTypes}">
										<a href="javascript:void(0);" onclick="setTimeType($(this),'${map.key}','#myForm')" ${orderForm.type == map.key ? 'class="active"' : ''}>${map.value}</a>
									</c:forEach>
									<input type="hidden" name="type" value="${orderForm.type}" />
								</div>
							</li>
							<li class="form-item-inline">
								<div class="sub-btns">
									<a class="layui-btn layui-btn-danger" href="javascript:submitClk()">确定</a>
									<a class="layui-btn layui-btn-normal" href="javascript:resetFunction('#myForm')">重置</a>
								</div>
							</li>
						</ul>
					</div>
				</div>
			</form>
			<div class="my-act-list-content">
				<div class="cl">
					<table class="layui-table" lay-size="sm">
						<colgroup>
							<col>
							<col>
							<col>
							<col>
							<col width="110px">
							<col width="110px">
							<col width="100px">
							<col width="100px">
							<col width="150px">
							<col width="100px">
						</colgroup>
						<thead>
							<tr>
								<th>订单名称</th>
								<th>下单者</th>
								<th>所属者</th>
								<th>商户</th>
								<th>类型</th>
								<th>金额</th>
								<th>支付方式</th>
								<th>状态</th>
								<th>更新时间</th>
								<th>操作</th>
							</tr>
						</thead>
						<tbody>
							<c:forEach var="orderForm" items="${orderForms}">
							<tr>
								<td class="ellipsis-1 " title="${orderForm.title}" onclick="openDialogNoButton('订单详情','${ctx}/order/order/orderInfo.do?id=${orderForm.id}','500px','620px')">
									<a style="width: 250px;cursor: pointer;" class="blue">${orderForm.title}</a>
								</td>
                                <td class="table-member" onclick="openDialogShow('用户名片','${ctx}/system/member/memberView.do?id=${orderForm.memberId}','400px','470px')">
                                    <div class="member-cell common-img">
                                        <div class="member-logo common-img">

                                            <img src="<c:if test="${orderForm.member.logo != null}">${orderForm.member.logo}?imageMogr2/auto-orient/crop/126x126</c:if>" alt="" onerror="txz.errImg(this)" onload="txz.imgLoad(this)">
                                        </div>
                                        <div class="member-name ellipsis-1"><a class="blue" title="${orderForm.member.realname}" style="cursor: pointer;">${orderForm.member.realname}</a></div>
                                    </div>
                                </td>
                                <td class="table-member" onclick="openDialogShow('用户名片','${ctx}/system/member/memberView.do?id=${orderForm.initiatorId}','400px','470px')">
                                    <div class="member-cell">
                                        <div class="member-logo common-img" >

                                            <img src="<c:if test="${orderForm.initiator.logo != null}">${orderForm.initiator.logo}?imageMogr2/auto-orient/crop/126x126</c:if>" alt="" onerror="txz.errImg(this)" onload="txz.imgLoad(this)">
                                        </div>
                                        <div class="member-name ellipsis-1"><a class="blue" title="${orderForm.initiator.realname}" style="cursor: pointer;">${orderForm.initiator.realname}</a></div>
                                    </div>
                                </td>
								<td><div class="ellipsis-1 ">${empty orderForm.merchantName ? orderForm.merchantId : orderForm.merchantName}</div></td>
								<td>
									<c:choose>
										<c:when test="${orderForm.type == 0}"><span>标准商品订单</span></c:when>
										<c:when test="${orderForm.type == 1}"><span>定制商品订单</span></c:when>
										<c:when test="${orderForm.type == 2}"><span>活动订单</span></c:when>
										<c:when test="${orderForm.type == 3}"><span>众筹订单</span></c:when>
										<c:when test="${orderForm.type == 4}"><span>套餐订单</span></c:when>
										<c:when test="${orderForm.type == 5}"><span>商城订单</span></c:when>
									</c:choose>
								</td>
								<td>￥<fmt:formatNumber value="${orderForm.payment}" pattern="0.00"/></td>
								<td>
									<div>
										<c:choose>
											<c:when test="${not empty orderForm.paymentWay && orderForm.paymentWay == 1}">微信</c:when>
											<c:when test="${not empty orderForm.paymentWay && orderForm.paymentWay == 0}">支付宝</c:when>
										</c:choose>
									</div>
								</td>
								<td>
									<c:choose>
										<c:when test="${orderForm.status == 0}">
											<span>审核中</span>
										</c:when>
										<c:when test="${orderForm.status == 1}">
											<span>待支付</span>
										</c:when>
										<c:when test="${orderForm.status == 2}">
											<span style="color: red;">已支付</span>
										</c:when>
										<c:when test="${orderForm.status == 3}">
											<span>其它</span>
										</c:when>
										<c:when test="${orderForm.status == 4}">
											<span>已退款</span>
										</c:when>
									</c:choose>
								</td>
								<td><fmt:formatDate value="${orderForm.updateDate}" pattern="yyyy-MM-dd HH:mm" /></td>
								<td class=" tb-opts">
									<div class="comm-opts">
										<a class="red" href="javascript:recoveryHistoryOrder('${orderForm.id}')" target="_self">恢复订单</a>
									</div>
								</td>
							</tr>
							</c:forEach>
						</tbody>
					</table>
				</div>
				<div id="page_content" class="page-container"></div>
			</div>
		</div><!--底部-->
		<%@include file="../include/footer.jsp"%>
	</section>
</div>

<script type="text/javascript" src="${ctx}/script/common/list.js"></script>
<script type="text/javascript" src="${ctx}/script/common/table_option.js"></script>
<script type="text/javascript">

    <%--showActive('${input.createStart}', '${input.createEnd}', '#timeType');--%>

	function submitClk(){
		var paramsArray = $("#myForm").serializeArray();
        var params = new Array();
        $.each(paramsArray, function (i, param) {
        	if(param.value != ""){
            	params.push(param.value);
        	}
        });

        if(params.length > 2) {
        	$("#flag").val(true);
        } else if(params.length == 2) {
        	$("#flag").val(false);
        }
        $("#myForm").submit();
	}

	$(function(){
        //加载分页
        loadPageNew({elem: 'page_content', totalCount: ${page.totalCount}, limit: ${page.limit}, page: ${page.page}, callback: submitClk});
        layui.use(['laydate'], function () {
            var laydate = layui.laydate;
            // 查询发布日期
            var start = {
                elem: 'input[name=createStart]'
            };

            var end = {
                elem: 'input[name=createEnd]'
            };
            laydate.render(start);
            laydate.render(end);
        });
	})
</script>
<script type="text/javascript">
    txz.initHeader({
        nav:[{
            name: '历史订单管理',
            curr: true
        }],
        info:'<span class="f12">共<b id="totalCount">${page.totalCount}</b>条记录</span>'
    });

    function recoveryHistoryOrder(orderId) {
        layer.confirm('确定要恢复订单吗？', {icon: 3, title: '系统提示'}, function (index) {
            txz.ajaxRequest({
                url: '${ctx}/order/orderHistory/recoveryHistoryOrder.do',
                params: {
                    orderId: orderId
                },
                callBack: function (ret) {
                    if (ret.success) {
                        util.layerMsgSuccess("恢复成功", function () {
                            submitFunction('#myForm');
                        })
                    } else {
                        util.layerMsgError("恢复失败");
                    }
                }
            });
        });
    }
</script>
</body>
</html>